package it.tukano.check;

/**
 * Utility to print a todo message
 * @author pgi
 */
public class Todo {

    /**
     * Instance initializer
     */
    public Todo() {
    }

    /**
     * Print the thread stack trace and a message
     * @param stackIndex the stack element to print
     * @param message the message tokens to print
     */
    static void print(int stackIndex, Object... message) {
        StringBuilder buffer = new StringBuilder();
        for (int i = 0; message != null && i < message.length; i++) {
            Object object = message[i];
            buffer.append(object);
        }
        String text = buffer.toString();
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        if (stackTrace != null && stackIndex < stackTrace.length) {
            System.out.println("TODO " + stackTrace[stackIndex].toString());
        } else {
            System.out.println("TODO (unrecognized location)");
        }
        System.out.println(buffer);
    }

    /**
     * Prints a default "Implement This" message
     * @param messageTokens optional list of arguments to append to the message
     */
    public static void implementThis(Object... messageTokens) {
        StringBuilder buffer = new StringBuilder();
        if (messageTokens == null || messageTokens.length == 0) {
            buffer.append("Implement this");
        } else {
            for (int i = 0; i < messageTokens.length; i++) {
                Object object = messageTokens[i];
                buffer.append(String.valueOf(object));
            }
        }
        print(3, buffer.toString());
    }
}
